import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class test17 {

    public static void main(String[] args) {
        Student s1=new Student("zhangsan",18,"男");
        Student s2=new Student("lihong",22,"女");
        Student s3=new Student("wangwu",19,"男");
        Student s4=new Student("wuwu",8,"女");
        Student s5=new Student("lilin",35,"男");

        List<Student> list=new ArrayList<Student>();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        list.add(s5);

        Map<String,Integer>map=new HashMap<>();
        for (Student stu : list) {

            String sex = stu.getSex();
            Integer cou = map.get(sex);
            if (cou==null){
                cou=1;
            }else {
                cou++;
            }
            map.put(sex,cou);
        }

        for (String kry : map.keySet()) {
            System.out.println(kry+"（"+map.get(kry)+")");
        }


        Map<String,Integer> map1=new HashMap<>();
        int count=0,count2=0;
        for (Student student : list) {
            int age = student.getAge();
            if (age<=18){
                count++;
            }else {
                count2++;
            }
            map1.put("成年",count);
            map1.put("未成年",count2);
        }
        System.out.println(map1);


    }
}
